export const addJS = (url: string, id: string): Promise<[]> => {
  return new Promise((resolve) => {
    const scriptObj = document.getElementById(id);
    if (scriptObj != null) {
      resolve([]);
    } else {
      const scriptDom = document.createElement("script");
      scriptDom.id = id;
      scriptDom.type = "text/javascript";
      scriptDom.src = url;
      document.head.appendChild(scriptDom);
      scriptDom.onload = function () {
        resolve([]);
      };
    }
  });
};
export const addWebviewJs = (): Promise<[]> => {
  // 二维码
  const url = "/js/uni.webview.1.5.5.js";
  return addJS(url, "addWebviewJs");
};

export const addWeixinJs = (): Promise<[]> => {
  // 二维码
  const url = "https://res.wx.qq.com/open/js/jweixin-1.4.0.js";
  return addJS(url, "addWeixinJs");
};
